package com.hd123.rumba.gwt.widget2e.client.dialog;

import com.hd123.rumba.gwt.widget2.client.form.RForm;
import com.hd123.rumba.gwt.widget2.client.form.RTextBox;

/**
 * 包含一个代码框和一个名称框的RFilterCallback实现
 * 
 * @author LiQi
 * 
 */
public class RCodeNameFilterCallbackImpl implements RFilterCallback {

  private CodeNameFilter filter;
  private RTextBox code;
  private RTextBox name;

  public RCodeNameFilterCallbackImpl() {
    filter = new CodeNameFilter();
  }

  public void buildConditions(RForm form) {
    form.setLabelWidth("30px");

    code = new RTextBox();
    code.setFieldCaption("代码");
    form.addField(code);

    name = new RTextBox();
    name.setFieldCaption("名称");
    form.addField(name);

    form.rebuild();
  }

  public void clearConditions() {
    code.setValue(null);
    name.setValue(null);
  }

  public void onQuery() {
    filter.setCode(code.getValue());
    filter.setName(name.getValue());
  }

  public CodeNameFilter getFilter() {
    return filter;
  }
}
